home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / lib / partman / init.d / 75auto_mountpoints < prev    next >
Text File  |  2009-10-28  |  2KB  |  82 lines

  1. #!/bin/sh
  2.  
  3. # Only run the first time.
  4. if [ -f /var/lib/partman/auto_mountpoints ]; then
  5.     exit 0
  6. fi
  7. [ -d /var/lib/partman ] || mkdir /var/lib/partman
  8. touch /var/lib/partman/auto_mountpoints
  9.  
  10. . /lib/partman/lib/base.sh
  11.  
  12. db_get partman/automount
  13. if [ "$RET" = false ]; then
  14.     exit 0
  15. fi
  16.  
  17. if type udevadm >/dev/null 2>&1; then
  18.     udevinfo () {
  19.         udevadm info "$@"
  20.     }
  21. fi
  22.  
  23. partitions=
  24. for dev in $DEVICES/*; do
  25.     [ -d "$dev" ] || continue
  26.     cd $dev
  27.     open_dialog PARTITIONS
  28.     while { read_line num id size type fs path name; [ "$id" ]; }; do
  29.         if udevinfo -q env -n "$path" 2>/dev/null | egrep -q 'ID_PATH=(pci-[^-]*-)?(ieee1394|usb)'; then
  30.             continue
  31.         fi
  32.         [ -f $id/detected_filesystem ] || continue
  33.         fs=$(cat $id/detected_filesystem)
  34.         if [ "$name" ]; then
  35.             mountpoint="$(/usr/lib/partconf/mountpoint "$path" "$fs" "$name")"
  36.         else
  37.             mountpoint="$(/usr/lib/partconf/mountpoint "$path" "$fs")"
  38.         fi
  39.         if [ "$mountpoint" ]; then
  40.             partitions="$partitions
  41. $dev,$id,$fs,$mountpoint"
  42.         fi
  43.     done
  44.     close_dialog
  45. done
  46.  
  47. IFS_SAVE="$IFS"
  48. IFS='
  49. '
  50. for part in $partitions; do
  51.     IFS="$IFS_SAVE"
  52.     dev="${part%%,*}"
  53.     cdr="${part#*,}"
  54.     id="${cdr%%,*}"
  55.     cdr="${cdr#*,}"
  56.     fs="${cdr%%,*}"
  57.     mountpoint="${cdr#*,}"
  58.  
  59.     [ -d "$dev/$id" ] || continue
  60.  
  61.     if [ -f "$dev/$id/method" ]; then
  62.         method="$(cat $dev/$id/method)"
  63.         if [ "$method" ]; then
  64.             # Already used for something else.
  65.             continue
  66.         fi
  67.     fi
  68.  
  69.     echo keep >"$dev/$id/method"
  70.     rm -f "$dev/$id/format"
  71.     >"$dev/$id/use_filesystem"
  72.     echo "$fs" >"$dev/$id/filesystem"
  73.     mkdir -p "$dev/$id/options"
  74.     echo "$mountpoint" >"$dev/$id/mountpoint"
  75.  
  76.     update_partition "$dev" "$id"
  77.  
  78.     IFS='
  79. '
  80. done
  81. IFS="$IFS_SAVE"
  82.